﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HKEA.CMS.Core.Models;
using HKEA.CMS.Core.BLL.Mtbl;
using System.Collections;
using HKEA.CMS.Core.BLL.Tbl;
using HKEA.CMS.Core.BLL.App;
using HKEA.CMS.Core.Utility;
using System.Text;
using System.Transactions;
namespace WebApplication
{
    public partial class M_AddressContactInformation : BasePage
    {
        static tblAddress staticeEnt;
        static app_tblContactInfo statictEntappInfo;

        tblCustomer customerENT = new tblCustomer();
        tblAddressBLL addressBLL = new tblAddressBLL();
        app_tblAddressBLL app_addressBLL = new app_tblAddressBLL();
        tblContactInfoBLL infoBLL = new tblContactInfoBLL();
        app_tblContactInfoBLL app_infoBLL = new app_tblContactInfoBLL();
        int telNum = 5;
        int faxNum = 5;
        int emailNum = 5;
        int webNum = 2;

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                InitPage();
            }
        }
        #region 页面加载
        private void InitPage()
        {
            customerENT = GetCustomerFromSession();
            if (customerENT != null)
            {
                AddToDropList();
                BindArea();
                app_tblAddress app_ENT = new app_tblAddress();
                app_ENT.AddressUID = customerENT.AddressUID;
                app_ENT=app_addressBLL.GetAppENTByENT(app_ENT);
                if (app_ENT != null)
                    SetAddressFromApp(app_ENT); 
                else
                    SetAddressFromTbl(customerENT.AddressUID);

                app_tblContactInfo app_InfoENT = new app_tblContactInfo();
                app_InfoENT.ContactInfoUID = customerENT.ContactInfoUID;
                app_InfoENT = app_infoBLL.GetAppENTByENT(app_InfoENT);

                if (app_InfoENT != null)
                {
                    SetInfoFromApp(app_InfoENT);
                }
                else
                {
                    SetInfoFromTbl(customerENT.ContactInfoUID);
                }
                GetBoundInfo();
                #region Log
                app_InfoENT = new app_tblContactInfo();
                statictEntappInfo = new app_tblContactInfo();
                statictEntappInfo = GetApp_InfoValue(app_InfoENT);
                #endregion

            }
            else
            {
                CustomerNotLoginOption();
            }
        }

        private void SetAddressFromApp(app_tblAddress app_addressENT)
        {
            if (app_addressENT != null)
            {
                hidAddressUID.Value = app_addressENT.AddressUID.ToString();
                txtArea_Chi.Text = app_addressENT.Area_Chi;
                txtArea_Eng.Text = app_addressENT.Area_Eng;
                txtCity_Chi.Text = app_addressENT.City_Chi;
                txtCity_Eng.Text = app_addressENT.City_Eng;
                txtDistrict_Chi.Text = app_addressENT.District_Chi;
                txtDistrict_Eng.Text = app_addressENT.District_Eng;
                txtFlat_Eng.Text = app_addressENT.Flat_Bldg_Eng;
                txtFlat_Chi.Text = app_addressENT.Flat_Bldg_Chi;
                txtProvince_Chi.Text = app_addressENT.Province_Chi;
                txtProvince_Eng.Text = app_addressENT.Province_Eng;
                txtStreet_Chi.Text = app_addressENT.Street_Rd_Chi;
                txtStreet_Eng.Text = app_addressENT.Street_Rd_Eng;
                txtPostCode.Text = app_addressENT.PostalCode;
                if (app_addressENT.CountryUID > 0)
                {
                    if (app_addressENT.mtblCountry.AreaUID > 0)
                    {
                        ddlArea.SelectedValue = app_addressENT.mtblCountry.AreaUID.ToString();
                    }
                    BindCountry();
                    ddlCountry.SelectedValue = app_addressENT.CountryUID.ToString();
                }
            }
        }
        private void SetInfoFromApp(app_tblContactInfo app_infoENT)
        {
            if (app_infoENT != null)
            {
                #region Info
                DropDownListTel1.SelectedValue = app_infoENT.Tel1_Type.ToString();
                TextBoxTC1.Text = app_infoENT.Tel1_CountryCode;
                TextBoxTA1.Text = app_infoENT.Tel1_AreaCode;
                TextBoxT1.Text = app_infoENT.Tel1;
                CheckBoxTD1.Checked = app_infoENT.Tel1_IsDNC == 1 ? true : false;
                CheckBoxTS1.Checked = app_infoENT.Tel1_IsSubscribe == 1 ? true : false;

                if (string.IsNullOrEmpty(app_infoENT.Tel1_CountryCode) && string.IsNullOrEmpty(app_infoENT.Tel1_AreaCode) && string.IsNullOrEmpty(app_infoENT.Tel1))
                {
                    PanelT1.Style.Add("display", "none");
                    telNum--;
                }

                DropDownListTel2.SelectedValue = app_infoENT.Tel2_Type.ToString();
                TextBoxTC2.Text = app_infoENT.Tel2_CountryCode;
                TextBoxTA2.Text = app_infoENT.Tel2_AreaCode;
                TextBoxT2.Text = app_infoENT.Tel2;
                CheckBoxTD2.Checked = app_infoENT.Tel2_IsDNC == 1 ? true : false;
                CheckBoxTS2.Checked = app_infoENT.Tel2_IsSubscribe == 1 ? true : false;
                if (string.IsNullOrEmpty(app_infoENT.Tel2_CountryCode) && string.IsNullOrEmpty(app_infoENT.Tel2_AreaCode) && string.IsNullOrEmpty(app_infoENT.Tel2))
                {
                    PanelT2.Style.Add("display", "none");
                    telNum--;
                }



                DropDownListTel3.SelectedValue = app_infoENT.Tel3_Type.ToString();
                TextBoxTC3.Text = app_infoENT.Tel3_CountryCode;
                TextBoxTA3.Text = app_infoENT.Tel3_AreaCode;
                TextBoxT3.Text = app_infoENT.Tel3;
                CheckBoxTD3.Checked = app_infoENT.Tel3_IsDNC == 1 ? true : false;
                CheckBoxTS3.Checked = app_infoENT.Tel3_IsSubscribe == 1 ? true : false;
                if (string.IsNullOrEmpty(app_infoENT.Tel3_CountryCode) && string.IsNullOrEmpty(app_infoENT.Tel3_AreaCode) && string.IsNullOrEmpty(app_infoENT.Tel3))
                {
                    PanelT3.Style.Add("display", "none");
                    telNum--;
                }

                DropDownListTel4.SelectedValue = app_infoENT.Tel4_Type.ToString();
                TextBoxTC4.Text = app_infoENT.Tel4_CountryCode;
                TextBoxTA4.Text = app_infoENT.Tel4_AreaCode;
                TextBoxT4.Text = app_infoENT.Tel4;
                CheckBoxTD4.Checked = app_infoENT.Tel4_IsDNC == 1 ? true : false;
                CheckBoxTS4.Checked = app_infoENT.Tel4_IsSubscribe == 1 ? true : false;
                if (string.IsNullOrEmpty(app_infoENT.Tel4_CountryCode) && string.IsNullOrEmpty(app_infoENT.Tel4_AreaCode) && string.IsNullOrEmpty(app_infoENT.Tel4))
                {
                    PanelT4.Style.Add("display", "none");
                    telNum--;
                }

                DropDownListTel5.SelectedValue = app_infoENT.Tel5_Type.ToString();
                TextBoxTC5.Text = app_infoENT.Tel5_CountryCode;
                TextBoxTA5.Text = app_infoENT.Tel5_AreaCode;
                TextBoxT5.Text = app_infoENT.Tel5;
                CheckBoxTD5.Checked = app_infoENT.Tel5_IsDNC == 1 ? true : false;
                CheckBoxTS5.Checked = app_infoENT.Tel5_IsSubscribe == 1 ? true : false;
                if (string.IsNullOrEmpty(app_infoENT.Tel5_CountryCode) && string.IsNullOrEmpty(app_infoENT.Tel5_AreaCode) && string.IsNullOrEmpty(app_infoENT.Tel5))
                {
                    PanelT5.Style.Add("display", "none");
                    telNum--;
                }
                if (telNum <= 0)
                    PanelT5.Style.Add("display", "true");
                #endregion
                #region Fax
                //Fax
                DropDownListFax1.SelectedValue = app_infoENT.Fax1_Type.ToString();
                TextBoxFC1.Text = app_infoENT.Fax1_CountryCode;
                TextBoxFA1.Text = app_infoENT.Fax1_AreaCode;
                TextBoxF1.Text = app_infoENT.Fax1;
                CheckBoxFD1.Checked = app_infoENT.Fax1_IsDNC == 1 ? true : false;
                CheckBoxFS1.Checked = app_infoENT.Fax1_IsSubscribe == 1 ? true : false;
                if (string.IsNullOrEmpty(app_infoENT.Fax1) && string.IsNullOrEmpty(app_infoENT.Fax1_AreaCode) && string.IsNullOrEmpty(app_infoENT.Fax2_CountryCode))
                {
                    PanelF1.Style.Add("display", "none");
                    faxNum--;
                }


                DropDownListFax2.SelectedValue = app_infoENT.Fax2_Type.ToString();
                TextBoxFC2.Text = app_infoENT.Fax2_CountryCode;
                TextBoxFA2.Text = app_infoENT.Fax2_AreaCode;
                TextBoxF2.Text = app_infoENT.Fax2;
                CheckBoxFD2.Checked = app_infoENT.Fax2_IsDNC == 1 ? true : false;
                CheckBoxFS2.Checked = app_infoENT.Fax2_IsSubscribe == 1 ? true : false;
                if (string.IsNullOrEmpty(app_infoENT.Fax2) && string.IsNullOrEmpty(app_infoENT.Fax2_AreaCode) && string.IsNullOrEmpty(app_infoENT.Fax2_CountryCode))
                {
                    PanelF2.Style.Add("display", "none");
                    faxNum--;
                }




                DropDownListFax3.SelectedValue = app_infoENT.Fax3_Type.ToString();
                TextBoxFC3.Text = app_infoENT.Fax3_CountryCode;
                TextBoxFA3.Text = app_infoENT.Fax3_AreaCode;
                TextBoxF3.Text = app_infoENT.Fax3;
                CheckBoxFD3.Checked = app_infoENT.Fax3_IsDNC == 1 ? true : false;
                CheckBoxFS3.Checked = app_infoENT.Fax3_IsSubscribe == 1 ? true : false;
                if (string.IsNullOrEmpty(app_infoENT.Fax3) && string.IsNullOrEmpty(app_infoENT.Fax3_AreaCode) && string.IsNullOrEmpty(app_infoENT.Fax3_CountryCode))
                {
                    PanelF3.Style.Add("display", "none");
                    faxNum--;
                }


                DropDownListFax4.SelectedValue = app_infoENT.Fax4_Type.ToString();
                TextBoxFC4.Text = app_infoENT.Fax4_CountryCode;
                TextBoxFA4.Text = app_infoENT.Fax4_AreaCode;
                TextBoxF4.Text = app_infoENT.Fax4;
                CheckBoxFD4.Checked = app_infoENT.Fax4_IsDNC == 1 ? true : false;
                CheckBoxFS4.Checked = app_infoENT.Fax4_IsSubscribe == 1 ? true : false;
                if (string.IsNullOrEmpty(app_infoENT.Fax4) && string.IsNullOrEmpty(app_infoENT.Fax4_AreaCode) && string.IsNullOrEmpty(app_infoENT.Fax4_CountryCode))
                {
                    PanelF4.Style.Add("display", "none");
                    faxNum--;
                }


                DropDownListFax5.SelectedValue = app_infoENT.Fax5_Type.ToString();
                TextBoxFC5.Text = app_infoENT.Fax5_CountryCode;
                TextBoxFA5.Text = app_infoENT.Fax5_AreaCode;
                TextBoxF5.Text = app_infoENT.Fax5;
                CheckBoxFD5.Checked = app_infoENT.Fax5_IsDNC == 1 ? true : false;
                CheckBoxFS5.Checked = app_infoENT.Fax5_IsSubscribe == 1 ? true : false;
                if (string.IsNullOrEmpty(app_infoENT.Fax5) && string.IsNullOrEmpty(app_infoENT.Fax5_AreaCode) && string.IsNullOrEmpty(app_infoENT.Fax5_CountryCode))
                {
                    PanelF5.Style.Add("display", "none");
                    faxNum--;
                }
                if (faxNum <= 0)
                    PanelF1.Style.Add("display", "true");
                #endregion
                #region Email
                //email 
                DropDownListEm1.SelectedValue = app_infoENT.Email1_Type.ToString();
                TextBoxEmail1.Text = app_infoENT.Email1;
                CheckBoxES1.Checked = app_infoENT.Email1_IsSubscribe == 1 ? true : false;
                CheckBoxHB1.Checked = app_infoENT.Email1_HardBounce == 1 ? true : false;
                if (string.IsNullOrEmpty(app_infoENT.Email1))
                {
                    PanelE5.Style.Add("display", "none");
                    emailNum--;
                }



                DropDownListEm2.SelectedValue = app_infoENT.Email2_Type.ToString();
                TextBoxEmail2.Text = app_infoENT.Email2;
                CheckBoxES2.Checked = app_infoENT.Email2_IsSubscribe == 1 ? true : false;
                CheckBoxHB2.Checked = app_infoENT.Email2_HardBounce == 1 ? true : false;
                if (string.IsNullOrEmpty(app_infoENT.Email2))
                {
                    PanelE2.Style.Add("display", "none");
                    emailNum--;
                }

                DropDownListEm3.SelectedValue = app_infoENT.Email3_Type.ToString();
                TextBoxEmail3.Text = app_infoENT.Email3;
                CheckBoxES3.Checked = app_infoENT.Email3_IsSubscribe == 1 ? true : false;
                CheckBoxHB3.Checked = app_infoENT.Email3_HardBounce == 1 ? true : false;
                if (string.IsNullOrEmpty(app_infoENT.Email3))
                {
                    PanelE3.Style.Add("display", "none");
                    emailNum--;
                }

                DropDownListEm4.SelectedValue = app_infoENT.Email4_Type.ToString();
                TextBoxEmail4.Text = app_infoENT.Email4;
                CheckBoxES4.Checked = app_infoENT.Email4_IsSubscribe == 1 ? true : false;
                CheckBoxHB4.Checked = app_infoENT.Email4_HardBounce == 1 ? true : false;
                if (string.IsNullOrEmpty(app_infoENT.Email4))
                {
                    PanelE4.Style.Add("display", "none");
                    emailNum--;
                }


                DropDownListEm5.SelectedValue = app_infoENT.Email5_Type.ToString();
                TextBoxEmail5.Text = app_infoENT.Email5;
                CheckBoxES5.Checked = app_infoENT.Email5_IsSubscribe == 1 ? true : false;
                CheckBoxHB5.Checked = app_infoENT.Email5_HardBounce == 1 ? true : false;
                if (string.IsNullOrEmpty(app_infoENT.Email5))
                {
                    PanelE5.Style.Add("display", "none");
                    emailNum--;
                }
                if (emailNum <= 0)
                    PanelE1.Style.Add("display", "true");
                #endregion
                #region WebSite
                //website
                DropDownListW1.SelectedValue = app_infoENT.Website1_Type.ToString();
                TextBoxWeb1.Text = app_infoENT.Website1;
                if (string.IsNullOrEmpty(app_infoENT.Website2))
                {
                    PanelW1.Style.Add("display", "none");
                    webNum--;
                }
                DropDownListW2.SelectedValue = app_infoENT.Website2_Type.ToString();
                TextBoxWeb2.Text = app_infoENT.Website2;
                if (string.IsNullOrEmpty(app_infoENT.Website2))
                {
                    PanelW2.Style.Add("display", "none");
                    webNum--;
                }
                if (webNum <= 0)
                    PanelW1.Style.Add("display", "true");
                #endregion
            }
            else
            { initInfo(); }
        }

        private void SetAddressFromTbl(int CustAddressUID)
        {
            tblAddress addressENT = new tblAddress();
            addressENT.AddressUID = CustAddressUID;
            addressENT = addressBLL.GetEntity(addressENT);
            if (addressENT != null)
            {
                hidAddressUID.Value = addressENT.AddressUID.ToString();
                txtArea_Chi.Text = addressENT.Area_Chi;
                txtArea_Eng.Text = addressENT.Area_Eng;
                txtCity_Chi.Text = addressENT.City_Chi;
                txtCity_Eng.Text = addressENT.City_Eng;
                txtDistrict_Chi.Text = addressENT.District_Chi;
                txtDistrict_Eng.Text = addressENT.District_Eng;
                txtFlat_Eng.Text = addressENT.Flat_Bldg_Eng;
                txtFlat_Chi.Text = addressENT.Flat_Bldg_Chi;
                txtProvince_Chi.Text = addressENT.Province_Chi;
                txtProvince_Eng.Text = addressENT.Province_Eng;
                txtStreet_Chi.Text = addressENT.Street_Rd_Chi;
                txtStreet_Eng.Text = addressENT.Street_Rd_Eng;
                txtPostCode.Text = addressENT.PostalCode;
                if (addressENT.CountryUID != null)
                {
                    if (addressENT.mtblCountry.AreaUID != null)
                    {
                        ddlArea.SelectedValue = addressENT.mtblCountry.AreaUID.ToString();
                    }
                    BindCountry();
                    ddlCountry.SelectedValue = addressENT.CountryUID.ToString();
                }
            }
        }
        private void SetInfoFromTbl(int CustInfoUID)
        {
            tblContactInfo infoENT = new tblContactInfo();
            infoENT.ContactInfoUID=CustInfoUID;
            infoENT=infoBLL.GetEntity(infoENT);
            if (infoENT != null)
            {

                #region Info
                DropDownListTel1.SelectedValue = infoENT.Tel1_Type.ToString();
                TextBoxTC1.Text = infoENT.Tel1_CountryCode;
                TextBoxTA1.Text = infoENT.Tel1_AreaCode;
                TextBoxT1.Text = infoENT.Tel1;
                CheckBoxTD1.Checked = infoENT.Tel1_IsDNC == 1 ? true : false;
                CheckBoxTS1.Checked = infoENT.Tel1_IsSubscribe == 1 ? true : false;

                if (string.IsNullOrEmpty(infoENT.Tel1_CountryCode) && string.IsNullOrEmpty(infoENT.Tel1_AreaCode) && string.IsNullOrEmpty(infoENT.Tel1))
                {
                    PanelT1.Style.Add("display", "none");
                    telNum--;
                }

                DropDownListTel2.SelectedValue = infoENT.Tel2_Type.ToString();
                TextBoxTC2.Text = infoENT.Tel2_CountryCode;
                TextBoxTA2.Text = infoENT.Tel2_AreaCode;
                TextBoxT2.Text = infoENT.Tel2;
                CheckBoxTD2.Checked = infoENT.Tel2_IsDNC == 1 ? true : false;
                CheckBoxTS2.Checked = infoENT.Tel2_IsSubscribe == 1 ? true : false;
                if (string.IsNullOrEmpty(infoENT.Tel2_CountryCode) && string.IsNullOrEmpty(infoENT.Tel2_AreaCode) && string.IsNullOrEmpty(infoENT.Tel2))
                {
                    PanelT2.Style.Add("display", "none");
                    telNum--;
                }



                DropDownListTel3.SelectedValue = infoENT.Tel3_Type.ToString();
                TextBoxTC3.Text = infoENT.Tel3_CountryCode;
                TextBoxTA3.Text = infoENT.Tel3_AreaCode;
                TextBoxT3.Text = infoENT.Tel3;
                CheckBoxTD3.Checked = infoENT.Tel3_IsDNC == 1 ? true : false;
                CheckBoxTS3.Checked = infoENT.Tel3_IsSubscribe == 1 ? true : false;
                if (string.IsNullOrEmpty(infoENT.Tel3_CountryCode) && string.IsNullOrEmpty(infoENT.Tel3_AreaCode) && string.IsNullOrEmpty(infoENT.Tel3))
                {
                    PanelT3.Style.Add("display", "none");
                    telNum--;
                }

                DropDownListTel4.SelectedValue = infoENT.Tel4_Type.ToString();
                TextBoxTC4.Text = infoENT.Tel4_CountryCode;
                TextBoxTA4.Text = infoENT.Tel4_AreaCode;
                TextBoxT4.Text = infoENT.Tel4;
                CheckBoxTD4.Checked = infoENT.Tel4_IsDNC == 1 ? true : false;
                CheckBoxTS4.Checked = infoENT.Tel4_IsSubscribe == 1 ? true : false;
                if (string.IsNullOrEmpty(infoENT.Tel4_CountryCode) && string.IsNullOrEmpty(infoENT.Tel4_AreaCode) && string.IsNullOrEmpty(infoENT.Tel4))
                {
                    PanelT4.Style.Add("display", "none");
                    telNum--;
                }

                DropDownListTel5.SelectedValue = infoENT.Tel5_Type.ToString();
                TextBoxTC5.Text = infoENT.Tel5_CountryCode;
                TextBoxTA5.Text = infoENT.Tel5_AreaCode;
                TextBoxT5.Text = infoENT.Tel5;
                CheckBoxTD5.Checked = infoENT.Tel5_IsDNC == 1 ? true : false;
                CheckBoxTS5.Checked = infoENT.Tel5_IsSubscribe == 1 ? true : false;
                if (string.IsNullOrEmpty(infoENT.Tel5_CountryCode) && string.IsNullOrEmpty(infoENT.Tel5_AreaCode) && string.IsNullOrEmpty(infoENT.Tel5))
                {
                    PanelT5.Style.Add("display", "none");
                    telNum--;
                }
                if (telNum <= 0)
                    PanelT5.Style.Add("display", "true");
                #endregion
                #region Fax
                //Fax
                DropDownListFax1.SelectedValue = infoENT.Fax1_Type.ToString();
                TextBoxFC1.Text = infoENT.Fax1_CountryCode;
                TextBoxFA1.Text = infoENT.Fax1_AreaCode;
                TextBoxF1.Text = infoENT.Fax1;
                CheckBoxFD1.Checked = infoENT.Fax1_IsDNC == 1 ? true : false;
                CheckBoxFS1.Checked = infoENT.Fax1_IsSubscribe == 1 ? true : false;
                if (string.IsNullOrEmpty(infoENT.Fax1) && string.IsNullOrEmpty(infoENT.Fax1_AreaCode) && string.IsNullOrEmpty(infoENT.Fax2_CountryCode))
                {
                    PanelF1.Style.Add("display", "none");
                    faxNum--;
                }


                DropDownListFax2.SelectedValue = infoENT.Fax2_Type.ToString();
                TextBoxFC2.Text = infoENT.Fax2_CountryCode;
                TextBoxFA2.Text = infoENT.Fax2_AreaCode;
                TextBoxF2.Text = infoENT.Fax2;
                CheckBoxFD2.Checked = infoENT.Fax2_IsDNC == 1 ? true : false;
                CheckBoxFS2.Checked = infoENT.Fax2_IsSubscribe == 1 ? true : false;
                if (string.IsNullOrEmpty(infoENT.Fax2) && string.IsNullOrEmpty(infoENT.Fax2_AreaCode) && string.IsNullOrEmpty(infoENT.Fax2_CountryCode))
                {
                    PanelF2.Style.Add("display", "none");
                    faxNum--;
                }




                DropDownListFax3.SelectedValue = infoENT.Fax3_Type.ToString();
                TextBoxFC3.Text = infoENT.Fax3_CountryCode;
                TextBoxFA3.Text = infoENT.Fax3_AreaCode;
                TextBoxF3.Text = infoENT.Fax3;
                CheckBoxFD3.Checked = infoENT.Fax3_IsDNC == 1 ? true : false;
                CheckBoxFS3.Checked = infoENT.Fax3_IsSubscribe == 1 ? true : false;
                if (string.IsNullOrEmpty(infoENT.Fax3) && string.IsNullOrEmpty(infoENT.Fax3_AreaCode) && string.IsNullOrEmpty(infoENT.Fax3_CountryCode))
                {
                    PanelF3.Style.Add("display", "none");
                    faxNum--;
                }


                DropDownListFax4.SelectedValue = infoENT.Fax4_Type.ToString();
                TextBoxFC4.Text = infoENT.Fax4_CountryCode;
                TextBoxFA4.Text = infoENT.Fax4_AreaCode;
                TextBoxF4.Text = infoENT.Fax4;
                CheckBoxFD4.Checked = infoENT.Fax4_IsDNC == 1 ? true : false;
                CheckBoxFS4.Checked = infoENT.Fax4_IsSubscribe == 1 ? true : false;
                if (string.IsNullOrEmpty(infoENT.Fax4) && string.IsNullOrEmpty(infoENT.Fax4_AreaCode) && string.IsNullOrEmpty(infoENT.Fax4_CountryCode))
                {
                    PanelF4.Style.Add("display", "none");
                    faxNum--;
                }


                DropDownListFax5.SelectedValue = infoENT.Fax5_Type.ToString();
                TextBoxFC5.Text = infoENT.Fax5_CountryCode;
                TextBoxFA5.Text = infoENT.Fax5_AreaCode;
                TextBoxF5.Text = infoENT.Fax5;
                CheckBoxFD5.Checked = infoENT.Fax5_IsDNC == 1 ? true : false;
                CheckBoxFS5.Checked = infoENT.Fax5_IsSubscribe == 1 ? true : false;
                if (string.IsNullOrEmpty(infoENT.Fax5) && string.IsNullOrEmpty(infoENT.Fax5_AreaCode) && string.IsNullOrEmpty(infoENT.Fax5_CountryCode))
                {
                    PanelF5.Style.Add("display", "none");
                    faxNum--;
                }
                if (faxNum <= 0)
                    PanelF1.Style.Add("display", "true");
                #endregion
                #region Email
                //email 
                DropDownListEm1.SelectedValue = infoENT.Email1_Type.ToString();
                TextBoxEmail1.Text = infoENT.Email1;
                CheckBoxES1.Checked = infoENT.Email1_IsSubscribe == 1 ? true : false;
                CheckBoxHB1.Checked = infoENT.Email1_HardBounce == 1 ? true : false;
                if (string.IsNullOrEmpty(infoENT.Email1))
                {
                    PanelE5.Style.Add("display", "none");
                    emailNum--;
                }



                DropDownListEm2.SelectedValue = infoENT.Email2_Type.ToString();
                TextBoxEmail2.Text = infoENT.Email2;
                CheckBoxES2.Checked = infoENT.Email2_IsSubscribe == 1 ? true : false;
                CheckBoxHB2.Checked = infoENT.Email2_HardBounce == 1 ? true : false;
                if (string.IsNullOrEmpty(infoENT.Email2))
                {
                    PanelE2.Style.Add("display", "none");
                    emailNum--;
                }

                DropDownListEm3.SelectedValue = infoENT.Email3_Type.ToString();
                TextBoxEmail3.Text = infoENT.Email3;
                CheckBoxES3.Checked = infoENT.Email3_IsSubscribe == 1 ? true : false;
                CheckBoxHB3.Checked = infoENT.Email3_HardBounce == 1 ? true : false;
                if (string.IsNullOrEmpty(infoENT.Email3))
                {
                    PanelE3.Style.Add("display", "none");
                    emailNum--;
                }

                DropDownListEm4.SelectedValue = infoENT.Email4_Type.ToString();
                TextBoxEmail4.Text = infoENT.Email4;
                CheckBoxES4.Checked = infoENT.Email4_IsSubscribe == 1 ? true : false;
                CheckBoxHB4.Checked = infoENT.Email4_HardBounce == 1 ? true : false;
                if (string.IsNullOrEmpty(infoENT.Email4))
                {
                    PanelE4.Style.Add("display", "none");
                    emailNum--;
                }


                DropDownListEm5.SelectedValue = infoENT.Email5_Type.ToString();
                TextBoxEmail5.Text = infoENT.Email5;
                CheckBoxES5.Checked = infoENT.Email5_IsSubscribe == 1 ? true : false;
                CheckBoxHB5.Checked = infoENT.Email5_HardBounce == 1 ? true : false;
                if (string.IsNullOrEmpty(infoENT.Email5))
                {
                    PanelE5.Style.Add("display", "none");
                    emailNum--;
                }
                if (emailNum <= 0)
                    PanelE1.Style.Add("display", "true");
                #endregion
                #region WebSite
                //website
                DropDownListW1.SelectedValue = infoENT.Website1_Type.ToString();
                TextBoxWeb1.Text = infoENT.Website1;
                if (string.IsNullOrEmpty(infoENT.Website2))
                {
                    PanelW1.Style.Add("display", "none");
                    webNum--;
                }
                DropDownListW2.SelectedValue = infoENT.Website2_Type.ToString();
                TextBoxWeb2.Text = infoENT.Website2;
                if (string.IsNullOrEmpty(infoENT.Website2))
                {
                    PanelW2.Style.Add("display", "none");
                    webNum--;
                }
                if (webNum <= 0)
                    PanelW1.Style.Add("display", "true");
                #endregion
            }
            else
            {
                initInfo();
            }
        }
        #endregion

        #region 页面加载初始化控件
        protected void BindArea()
        {
            mtblArea areaENT = new mtblArea();
            areaENT.Deleted = 0;
            mtblAreaBLL areaBLL = new mtblAreaBLL();
            var list = areaBLL.GetListByENT(areaENT);
            ddlArea.DataSource = list;
            ddlArea.DataTextField = "Area_Chi";
            ddlArea.DataValueField = "AreaUID";
            ddlArea.DataBind();
            BindCountry();
        }
        protected void BindCountry()
        {
            mtblCountry countryENT = new mtblCountry();
            mtblCountryBLL countryBLL = new mtblCountryBLL();
            countryENT.Deleted = 0;
            int areaUID = Convert.ToInt32(ddlArea.SelectedValue);
            countryENT.AreaUID = areaUID;
            var list = countryBLL.GetListByENT(countryENT);
            if (list.Count > 0)
            {
                ddlCountry.DataSource = list;
                ddlCountry.DataTextField = "Country_Chi";
                ddlCountry.DataValueField = "CountryUID";
                ddlCountry.DataBind();
            }
        }
        private void AddToDropList()
        {
            Hashtable tellHas = Constant.InfoType.tellType;
            Hashtable FaxHas = Constant.InfoType.FaxType;
            Hashtable MailHas = Constant.InfoType.EmailType;
            Hashtable WebHas = Constant.InfoType.WebType;
            //telphone
            DropDownListTel1.DataSource = DropDownListTel2.DataSource = DropDownListTel3.DataSource = DropDownListTel4.DataSource = DropDownListTel5.DataSource = tellHas;
            DropDownListTel1.DataTextField = DropDownListTel2.DataTextField = DropDownListTel3.DataTextField = DropDownListTel4.DataTextField = DropDownListTel5.DataTextField = "value";
            DropDownListTel1.DataValueField = DropDownListTel2.DataValueField = DropDownListTel3.DataValueField = DropDownListTel4.DataValueField = DropDownListTel5.DataValueField = "key";
            DropDownListTel1.DataBind();
            DropDownListTel2.DataBind();
            DropDownListTel3.DataBind();
            DropDownListTel4.DataBind();
            DropDownListTel5.DataBind();
            //Fax
            DropDownListFax1.DataSource = DropDownListFax2.DataSource = DropDownListFax3.DataSource = DropDownListFax4.DataSource = DropDownListFax5.DataSource = FaxHas;
            DropDownListFax1.DataTextField = DropDownListFax2.DataTextField = DropDownListFax3.DataTextField = DropDownListFax4.DataTextField = DropDownListFax5.DataTextField = "value";
            DropDownListFax1.DataValueField = DropDownListFax2.DataValueField = DropDownListFax3.DataValueField = DropDownListFax4.DataValueField = DropDownListFax5.DataValueField = "key";
            DropDownListFax1.DataBind();
            DropDownListFax2.DataBind();
            DropDownListFax3.DataBind();
            DropDownListFax4.DataBind();
            DropDownListFax5.DataBind();
            //Mail
            DropDownListEm1.DataSource = DropDownListEm2.DataSource = DropDownListEm3.DataSource = DropDownListEm4.DataSource = DropDownListEm5.DataSource = MailHas;
            DropDownListEm1.DataTextField = DropDownListEm2.DataTextField = DropDownListEm3.DataTextField = DropDownListEm4.DataTextField = DropDownListEm5.DataTextField = "value";
            DropDownListEm1.DataValueField = DropDownListEm2.DataValueField = DropDownListEm3.DataValueField = DropDownListEm4.DataValueField = DropDownListEm5.DataValueField = "key";
            DropDownListEm1.DataBind();
            DropDownListEm2.DataBind();
            DropDownListEm3.DataBind();
            DropDownListEm4.DataBind();
            DropDownListEm5.DataBind();
            //WEBsit
            DropDownListW1.DataSource = DropDownListW2.DataSource=WebHas;
            DropDownListW1.DataTextField =DropDownListW2.DataTextField= "value";
            DropDownListW1.DataValueField = DropDownListW2.DataValueField = "key";
            DropDownListW1.DataBind();
            DropDownListW2.DataBind();
        }
        /// 新添加时 Contact Information
        private void initInfo()
        {
            //telephone
            PanelT1.Visible = true;
            PanelT2.Style.Add("display", "none");
            PanelT3.Style.Add("display", "none");
            PanelT4.Style.Add("display", "none");
            PanelT5.Style.Add("display", "none");

            //fax
            PanelF1.Visible = true;
            PanelF2.Style.Add("display", "none");
            PanelF3.Style.Add("display", "none");
            PanelF4.Style.Add("display", "none");
            PanelF5.Style.Add("display", "none");

            //email
            PanelE1.Visible = true;
            PanelE2.Style.Add("display", "none");
            PanelE3.Style.Add("display", "none");
            PanelE4.Style.Add("display", "none");
            PanelE5.Style.Add("display", "none");

            //website
            PanelW1.Visible = true;
            PanelW2.Style.Add("display", "none");


        }
        #endregion
        #region 获取文本值
        private app_tblAddress GetApp_AddressValue(app_tblAddress app_addressENT)
        {
            app_addressENT.Area_Chi = txtArea_Chi.Text;
            app_addressENT.Area_Eng = txtArea_Eng.Text;
            app_addressENT.City_Chi = txtCity_Chi.Text;
            app_addressENT.City_Eng = txtCity_Eng.Text;
            app_addressENT.CountryUID = Convert.ToInt32(ddlCountry.SelectedValue);
            app_addressENT.CreationDate = DateTime.Now;
            app_addressENT.District_Chi = txtDistrict_Chi.Text;
            app_addressENT.District_Eng = txtDistrict_Eng.Text;
            app_addressENT.Flat_Bldg_Chi = txtFlat_Chi.Text;
            app_addressENT.Flat_Bldg_Eng = txtFlat_Eng.Text;
            app_addressENT.LastModifyDate = DateTime.Now;
            app_addressENT.PostalCode = txtPostCode.Text;
            app_addressENT.Province_Chi = txtProvince_Chi.Text;
            app_addressENT.Province_Eng = txtProvince_Eng.Text;
            app_addressENT.Street_Rd_Chi = txtStreet_Chi.Text;
            app_addressENT.Street_Rd_Eng = txtStreet_Eng.Text;
            mtblCountry countryENT = new mtblCountry();
            countryENT = app_addressENT.mtblCountry;
            StringBuilder strBuilderEng = new StringBuilder();
            strBuilderEng.Append(txtFlat_Eng.Text).Append(txtStreet_Eng.Text).Append(txtArea_Eng.Text).Append(txtDistrict_Eng.Text).Append(txtCity_Eng.Text).Append(txtProvince_Eng.Text);
            StringBuilder strBuilderChi = new StringBuilder();
            if (countryENT != null)
            {
                strBuilderEng.Append(countryENT.Country_Eng);

                if (countryENT.AreaUID > 0)
                {
                    mtblArea areaENT = new mtblArea();
                    areaENT.AreaUID = (int)countryENT.AreaUID;
                    mtblAreaBLL bll = new mtblAreaBLL();
                    areaENT = bll.GetEntity(areaENT);
                    if (areaENT != null)
                    {
                        strBuilderEng.Append(areaENT.Area_Eng);
                        strBuilderChi.Append(areaENT.Area_Chi);
                    }
                }
                strBuilderChi.Append(countryENT.Country_Chi);
            }
            strBuilderChi.Append(txtProvince_Chi.Text).Append(txtCity_Chi.Text).Append(txtDistrict_Chi.Text).Append(txtArea_Chi.Text).Append(txtStreet_Chi.Text).Append(txtFlat_Chi.Text);
            app_addressENT.FullAdd_Chi = strBuilderChi.ToString();
            app_addressENT.FullAdd_Eng = strBuilderEng.ToString();
            return app_addressENT;
        }
        private app_tblContactInfo GetApp_InfoValue(app_tblContactInfo app_infoENT)
        {
            #region Email
            app_infoENT.Email1 = TextBoxEmail1.Text;
            app_infoENT.Email1_IsSubscribe = CheckBoxES1.Checked ? 1 : 0;
            app_infoENT.Email1_Type = Convert.ToInt32(DropDownListEm1.SelectedValue);
            app_infoENT.Email1_HardBounce = CheckBoxHB1.Checked ? 1 : 0;
            app_infoENT.Email2 = TextBoxEmail2.Text;
            app_infoENT.Email2_IsSubscribe = CheckBoxES2.Checked ? 1 : 0;
            app_infoENT.Email2_Type = Convert.ToInt32(DropDownListEm2.SelectedValue);
            app_infoENT.Email2_HardBounce = CheckBoxHB2.Checked ? 1 : 0;
            app_infoENT.Email3 = TextBoxEmail3.Text;
            app_infoENT.Email3_IsSubscribe = CheckBoxES3.Checked ? 1 : 0;
            app_infoENT.Email3_Type = Convert.ToInt32(DropDownListEm3.SelectedValue);
            app_infoENT.Email3_HardBounce = CheckBoxHB3.Checked ? 1 : 0;
            app_infoENT.Email4 = TextBoxEmail4.Text;
            app_infoENT.Email4_IsSubscribe = CheckBoxES4.Checked ? 1 : 0;
            app_infoENT.Email4_Type = Convert.ToInt32(DropDownListEm4.SelectedValue);
            app_infoENT.Email4_HardBounce = CheckBoxHB4.Checked ? 1 : 0;
            app_infoENT.Email5 = TextBoxEmail5.Text;
            app_infoENT.Email5_IsSubscribe = CheckBoxES5.Checked ? 1 : 0;
            app_infoENT.Email5_Type = Convert.ToInt32(DropDownListEm5.SelectedValue);
            app_infoENT.Email5_HardBounce = CheckBoxHB5.Checked ? 1 : 0;
            #endregion
            #region Fax
            app_infoENT.Fax1 = TextBoxF1.Text;
            app_infoENT.Fax1_AreaCode = TextBoxFA1.Text;
            app_infoENT.Fax1_CountryCode = TextBoxFC1.Text;
            app_infoENT.Fax1_IsDNC = CheckBoxFD1.Checked ? 1 : 0;
            app_infoENT.Fax1_IsSubscribe = CheckBoxFS1.Checked ? 1 : 0;
            app_infoENT.Fax1_Type = Convert.ToInt32(DropDownListFax1.SelectedValue);

            app_infoENT.Fax2 = TextBoxF2.Text;
            app_infoENT.Fax2_AreaCode = TextBoxFA2.Text;
            app_infoENT.Fax2_CountryCode = TextBoxFC2.Text;
            app_infoENT.Fax2_IsDNC = CheckBoxFD2.Checked ? 1 : 0;
            app_infoENT.Fax2_IsSubscribe = CheckBoxFS2.Checked ? 1 : 0;
            app_infoENT.Fax2_Type = Convert.ToInt32(DropDownListFax2.SelectedValue);

            app_infoENT.Fax3 = TextBoxF3.Text;
            app_infoENT.Fax3_AreaCode = TextBoxFA3.Text;
            app_infoENT.Fax3_CountryCode = TextBoxFC3.Text;
            app_infoENT.Fax3_IsDNC = CheckBoxFD3.Checked ? 1 : 0;
            app_infoENT.Fax3_IsSubscribe = CheckBoxFS3.Checked ? 1 : 0;
            app_infoENT.Fax3_Type = Convert.ToInt32(DropDownListFax3.SelectedValue);

            app_infoENT.Fax4 = TextBoxF4.Text;
            app_infoENT.Fax4_AreaCode = TextBoxFA4.Text;
            app_infoENT.Fax4_CountryCode = TextBoxFC4.Text;
            app_infoENT.Fax4_IsDNC = CheckBoxFD4.Checked ? 1 : 0;
            app_infoENT.Fax4_IsSubscribe = CheckBoxFS4.Checked ? 1 : 0;
            app_infoENT.Fax4_Type = Convert.ToInt32(DropDownListFax4.SelectedValue);

            app_infoENT.Fax5 = TextBoxF5.Text;
            app_infoENT.Fax5_AreaCode = TextBoxFA5.Text;
            app_infoENT.Fax5_CountryCode = TextBoxFC5.Text;
            app_infoENT.Fax5_IsDNC = CheckBoxFD5.Checked ? 1 : 0;
            app_infoENT.Fax5_IsSubscribe = CheckBoxFS5.Checked ? 1 : 0;
            app_infoENT.Fax5_Type = Convert.ToInt32(DropDownListFax5.SelectedValue);
            #endregion
            #region Tel
            app_infoENT.Tel1 = TextBoxT1.Text;
            app_infoENT.Tel1_AreaCode = TextBoxTA1.Text;
            app_infoENT.Tel1_CountryCode = TextBoxTC1.Text;
            app_infoENT.Tel1_IsDNC = CheckBoxTD1.Checked ? 1 : 0;
            app_infoENT.Tel1_IsSubscribe = CheckBoxTS1.Checked ? 1 : 0;
            app_infoENT.Tel1_Type = Convert.ToInt32(DropDownListTel1.SelectedValue);

            app_infoENT.Tel2 = TextBoxT2.Text;
            app_infoENT.Tel2_AreaCode = TextBoxTA2.Text;
            app_infoENT.Tel2_CountryCode = TextBoxTC2.Text;
            app_infoENT.Tel2_IsDNC = CheckBoxTD2.Checked ? 1 : 0;
            app_infoENT.Tel2_IsSubscribe = CheckBoxTS2.Checked ? 1 : 0;
            app_infoENT.Tel2_Type = Convert.ToInt32(DropDownListTel2.SelectedValue);

            app_infoENT.Tel3 = TextBoxT3.Text;
            app_infoENT.Tel3_AreaCode = TextBoxTA3.Text;
            app_infoENT.Tel3_CountryCode = TextBoxTC3.Text;
            app_infoENT.Tel3_IsDNC = CheckBoxTD3.Checked ? 1 : 0;
            app_infoENT.Tel3_IsSubscribe = CheckBoxTS3.Checked ? 1 : 0;
            app_infoENT.Tel3_Type = Convert.ToInt32(DropDownListTel3.SelectedValue);

            app_infoENT.Tel4 = TextBoxT4.Text;
            app_infoENT.Tel4_AreaCode = TextBoxTA4.Text;
            app_infoENT.Tel4_CountryCode = TextBoxTC4.Text;
            app_infoENT.Tel4_IsDNC = CheckBoxTD4.Checked ? 1 : 0;
            app_infoENT.Tel4_IsSubscribe = CheckBoxTS4.Checked ? 1 : 0;
            app_infoENT.Tel4_Type = Convert.ToInt32(DropDownListTel4.SelectedValue);

            app_infoENT.Tel5 = TextBoxT5.Text;
            app_infoENT.Tel5_AreaCode = TextBoxTA5.Text;
            app_infoENT.Tel5_CountryCode = TextBoxTC5.Text;
            app_infoENT.Tel5_IsDNC = CheckBoxTD5.Checked ? 1 : 0;
            app_infoENT.Tel5_IsSubscribe = CheckBoxTS5.Checked ? 1 : 0;
            app_infoENT.Tel5_Type = Convert.ToInt32(DropDownListTel5.SelectedValue);
            #endregion
            #region WebSite
            app_infoENT.Website1 = TextBoxWeb1.Text;
            app_infoENT.Website1_Type = Convert.ToInt32(DropDownListW1.SelectedValue);
            app_infoENT.Website2 = TextBoxWeb2.Text;
            app_infoENT.Website2_Type = Convert.ToInt32(DropDownListW2.SelectedValue);
            #endregion
            return app_infoENT;
        }
        #endregion
        #region 按钮事件

        private void SaveApp_Address(app_tblAddress app_addressENT)
        {
            app_tblAddress app_ENT = new app_tblAddress();
            app_ENT.AddressUID = app_addressENT.AddressUID;
            app_ENT=app_addressBLL.GetAppENTByENT(app_ENT);
            if (app_ENT != null)
            {
                app_addressENT.AppAddressUID = app_ENT.AppAddressUID;
                app_addressBLL.UpdateENT(app_addressENT);
            }
            else
                app_addressBLL.InsertENT(app_addressENT);
        }

        private void SaveApp_Info(app_tblContactInfo app_infoENT)
        {
            app_tblContactInfo tempENT = new app_tblContactInfo();
            tempENT.ContactInfoUID = app_infoENT.ContactInfoUID;
            tempENT=app_infoBLL.GetAppENTByENT(tempENT);
            if (tempENT != null)
            {
                app_infoENT.AppContactInfoUID = tempENT.AppContactInfoUID;
                app_infoBLL.UpdateENT(app_infoENT);
            }
            else
                app_infoBLL.InsertENT(app_infoENT);
        }

        protected void lkBtnSave_Click(object sender, EventArgs e)
        {
            customerENT = GetCustomerFromSession();
            if (customerENT != null)
            {
                app_tblAddress app_addressENT = new app_tblAddress();
                app_tblContactInfo app_infoENT = new app_tblContactInfo();

                app_addressENT = GetApp_AddressValue(app_addressENT);
                app_infoENT = GetApp_InfoValue(app_infoENT);

                app_addressENT.AddressUID = customerENT.AddressUID;
                app_infoENT.ContactInfoUID = customerENT.ContactInfoUID;

                TransactionOptions options = new TransactionOptions();
                options.Timeout = new TimeSpan(0, 5, 0);
                options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
                {
                    SaveApp_Address(app_addressENT);
                    SaveApp_Info(app_infoENT);
                    WriteToLog();
                    try
                    {
                        scope.Complete();
                        lblMeg.Text = ResourceManage.GetResourceString("msg200004");
                    }
                    catch (Exception er)
                    {
                        lblMeg.Text = ResourceManage.GetResourceString("msg200003");
                    }
                }
            }
            else
            {
                CustomerNotLoginOption();
            }
        }
        #endregion

        protected void ddlArea_SelectedIndexChanged(object sender, EventArgs e)
        {
            BindCountry();
        }

        #region
        /// <summary>
        /// 
        /// </summary>
        protected void WriteToLog()
        {
            string ChangeLoge = string.Empty;
            string LoginName = tblCust_WebLoginBLL.GetInstance().GetENT(GetMemberLoginUID()).LoginName.ToString();
            #region 获取最新的数据判断更改了什么
            if (Val(staticeEnt.Area_Chi) != txtArea_Chi.Text) { ChangeLoge += ", 地區 change to " + txtArea_Chi.Text; }
            if (Val(staticeEnt.Area_Eng) != txtArea_Eng.Text) { ChangeLoge += " , Area change to " + txtArea_Eng.Text; }
            if (Val(staticeEnt.City_Chi) != txtCity_Chi.Text) { ChangeLoge += " , 城市 change to " + txtCity_Chi.Text; }
            if (Val(staticeEnt.City_Eng) != txtCity_Eng.Text) { ChangeLoge += " , City change to " + txtCity_Eng.Text; }
            if (Val(staticeEnt.District_Chi) != txtDistrict_Chi.Text) { ChangeLoge += " , 區域 change to " + txtDistrict_Chi.Text; }
            if (Val(staticeEnt.District_Eng) != txtDistrict_Eng.Text) { ChangeLoge += " , District change to " + txtDistrict_Eng.Text; }
            if (Val(staticeEnt.Flat_Bldg_Eng) != txtFlat_Eng.Text) { ChangeLoge += " , 室, 樓層, 大廈 change to " + txtFlat_Eng.Text; }
            if (Val(staticeEnt.Flat_Bldg_Chi) != txtFlat_Chi.Text) { ChangeLoge += " , Flat_Bldg change to " + txtFlat_Chi.Text; }
            if (Val(staticeEnt.Province_Chi) != txtProvince_Chi.Text) { ChangeLoge += " , 州, 省 change to " + txtProvince_Chi.Text; }
            if (Val(staticeEnt.Province_Eng) != txtProvince_Eng.Text) { ChangeLoge += " , Province change to " + txtProvince_Eng.Text; }
            if (Val(staticeEnt.Street_Rd_Chi) != txtStreet_Chi.Text) { ChangeLoge += " , 街道 change to " + txtStreet_Chi.Text; }
            if (Val(staticeEnt.Street_Rd_Eng) != txtStreet_Eng.Text) { ChangeLoge += " , Street_Rd change to" + txtStreet_Eng.Text; }
            if (Val(staticeEnt.PostalCode) != txtPostCode.Text) { ChangeLoge += " , PostalCode change to " + txtPostCode.Text; }
            if (Val(staticeEnt.Department_Eng) != ddlArea.SelectedItem.Text) { ChangeLoge += " , Continent change to " + ddlArea.SelectedItem.Text; }
            if (Val(staticeEnt.Department_Chi) != ddlCountry.SelectedItem.Text) { ChangeLoge += " , Country change to" + ddlCountry.SelectedItem.Text; }
            ChangeLoge += method(ChangeLoge);

            #endregion
            tblHistory entlog = new tblHistory();
            Literal CompanyName = usermeg.FindControl("ltlCompanyName_eng") as Literal;
            entlog.HistoryCatUID = 2;
            entlog.HistoryTypeUID = 3;
            entlog.CustomerUID = GetEnt();
            entlog.Cust_MemberUID = 0;
            entlog.ContactPersonUID = 0;
            entlog.History_Detail = LoginName + " {" + CompanyName.Text + "}{AddressContactInformation} " + ChangeLoge;
            entlog.LastModifyBy = LoginName;
            int tal = tblHistoryBLL.GetInstance().InsertENT(entlog);
        }
        /// <summary>
        /// 获取绑定好后的数据到静态对象staticeEnt中
        /// </summary>
        protected void GetBoundInfo()
        {
            staticeEnt = new tblAddress();
            staticeEnt.Area_Chi = txtArea_Chi.Text;
            staticeEnt.Area_Eng = txtArea_Eng.Text;
            staticeEnt.City_Chi = txtCity_Chi.Text;
            staticeEnt.City_Eng = txtCity_Eng.Text;
            staticeEnt.District_Chi = txtDistrict_Chi.Text;
            staticeEnt.District_Eng = txtDistrict_Eng.Text;
            staticeEnt.Flat_Bldg_Eng = txtFlat_Eng.Text;
            staticeEnt.Flat_Bldg_Chi = txtFlat_Chi.Text;
            staticeEnt.Province_Chi = txtProvince_Chi.Text;
            staticeEnt.Province_Eng = txtProvince_Eng.Text;
            staticeEnt.Street_Rd_Chi = txtStreet_Chi.Text;
            staticeEnt.Street_Rd_Eng = txtStreet_Eng.Text;
            staticeEnt.PostalCode = txtPostCode.Text;
            staticeEnt.Department_Eng=ddlArea.SelectedItem.Text;
            staticeEnt.Department_Chi = ddlCountry.SelectedItem.Text;
        }
        /// <summary>
        ///判断Tel Fax Email Website有没有更改
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        protected string method(string str) {
            if (statictEntappInfo != null)
            {
                app_tblContactInfo app_infoENT = new app_tblContactInfo();
                app_infoENT = GetApp_InfoValue(app_infoENT);
                if (statictEntappInfo.Tel1 != app_infoENT.Tel1 | statictEntappInfo.Tel2 != app_infoENT.Tel2 | statictEntappInfo.Tel3 != app_infoENT.Tel3 | statictEntappInfo.Tel4 != app_infoENT.Tel4 | statictEntappInfo.Tel5 != app_infoENT.Tel5) {
                    str += "Tel have change; ";
                }
                if (statictEntappInfo.Tel1_IsDNC != app_infoENT.Tel1_IsDNC | statictEntappInfo.Tel2_IsDNC != app_infoENT.Tel2_IsDNC | statictEntappInfo.Tel3_IsDNC != app_infoENT.Tel3_IsDNC | statictEntappInfo.Tel4_IsDNC != app_infoENT.Tel4_IsDNC | statictEntappInfo.Tel5_IsDNC != app_infoENT.Tel5_IsDNC)
                {
                    str += "Tel DNC have change; ";
                }
                if (statictEntappInfo.Tel1_IsSubscribe != app_infoENT.Tel1_IsSubscribe | statictEntappInfo.Tel2_IsSubscribe != app_infoENT.Tel2_IsSubscribe | statictEntappInfo.Tel3_IsSubscribe != app_infoENT.Tel3_IsSubscribe | statictEntappInfo.Tel4_IsSubscribe != app_infoENT.Tel4_IsSubscribe | statictEntappInfo.Tel5_IsSubscribe != app_infoENT.Tel5_IsSubscribe)
                {
                    str += "Tel Subscrib have change; ";
                }
                if (statictEntappInfo.Fax1 != app_infoENT.Fax1 | statictEntappInfo.Fax2 != app_infoENT.Fax2 | statictEntappInfo.Fax3 != app_infoENT.Fax3 | statictEntappInfo.Fax4 != app_infoENT.Fax4 | statictEntappInfo.Fax5 != app_infoENT.Fax5)
                {
                    str += "Fax have change";
                }
                if (statictEntappInfo.Fax1_IsDNC != app_infoENT.Fax1_IsDNC | statictEntappInfo.Fax2_IsDNC != app_infoENT.Fax2_IsDNC | statictEntappInfo.Fax3_IsDNC != app_infoENT.Fax3_IsDNC | statictEntappInfo.Fax4_IsDNC != app_infoENT.Fax4_IsDNC | statictEntappInfo.Fax5_IsDNC != app_infoENT.Fax5_IsDNC)
                {
                    str += "Fax DNC chave change";
                }
                if (statictEntappInfo.Fax1_IsSubscribe != app_infoENT.Fax1_IsSubscribe | statictEntappInfo.Fax2_IsSubscribe != app_infoENT.Fax2_IsSubscribe | statictEntappInfo.Fax3_IsSubscribe != app_infoENT.Fax3_IsSubscribe | statictEntappInfo.Fax4_IsSubscribe != app_infoENT.Fax4_IsSubscribe | statictEntappInfo.Fax5_IsSubscribe != app_infoENT.Fax5_IsSubscribe)
                {
                    str += "Fax Subscribe have change";
                }
                if (statictEntappInfo.Email1 != app_infoENT.Email1 | statictEntappInfo.Email2 != app_infoENT.Email2 | statictEntappInfo.Email3 != app_infoENT.Email3 | statictEntappInfo.Email4 != app_infoENT.Email4 | statictEntappInfo.Email5!=app_infoENT.Email5)
                {
                    str += "Email have change";
                }
                if (statictEntappInfo.Email1_IsSubscribe != app_infoENT.Email1_IsSubscribe | statictEntappInfo.Email2_IsSubscribe != app_infoENT.Email2_IsSubscribe | statictEntappInfo.Email3_IsSubscribe != app_infoENT.Email3_IsSubscribe | statictEntappInfo.Email4_IsSubscribe != app_infoENT.Email4_IsSubscribe | statictEntappInfo.Email5_IsSubscribe != app_infoENT.Email5_IsSubscribe)
                {
                    str += "Email Subscribe have change";
                }
                if (statictEntappInfo.Email1_HardBounce != app_infoENT.Email1_HardBounce | statictEntappInfo.Email2_HardBounce != app_infoENT.Email2_HardBounce | statictEntappInfo.Email3_HardBounce != app_infoENT.Email3_HardBounce | statictEntappInfo.Email4_HardBounce != app_infoENT.Email4_HardBounce | statictEntappInfo.Email5_HardBounce != app_infoENT.Email5_HardBounce)
                {
                    str += "Email Subscribe have change";
                }
                if (statictEntappInfo.Website1 != app_infoENT.Website1 | statictEntappInfo.Website2 != app_infoENT.Website2)
                {
                    str += "Website have change";
                }
                if (statictEntappInfo.Website1_Type != app_infoENT.Website1_Type | statictEntappInfo.Website2_Type != app_infoENT.Website2_Type)
                {
                    str += "Website type have change";
                }

            }
            return str;
        }
        protected string Val(string str)
        {
            if (string.IsNullOrEmpty(str))
                str = "";
            return str;
        }
        #endregion
    }
}